<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">


<ui:composition template="/templates/layout.xhtml">

	<ui:define name="corpo">

		<h:form id="form">

			<h:inputHidden value="#{fornecedorBean.fornecedor.idFornecedor}" />
			<h:inputHidden value="#{fornecedorBean.endereco.idEndereco}" />
			<p:accordionPanel>
				<p:tab title="Dados do Fornecedor" closable="false">
					<p:fieldset>
						<div id="cadastro">
							<div style="margin-top: 10px;">
								<br />

								<h:panelGrid columns="2">
									<h:outputLabel value="Razão Social :" for="razaosocial"  style="font-weight:bold" />
									<h:panelGroup>
										<p:inputText id="nome" label="Nome"
											value="#{fornecedorBean.fornecedor.razaoSocial}"
											required="true" requiredMessage="Informe o seu nome"
											size="30" style="heght:30px;" />
										<span id="erro"> <h:message for="nome" /></span>
									</h:panelGroup>

									<h:outputLabel value="CNPJ :" for="cnpj"  style="font-weight:bold" />
									<h:panelGroup>
										<p:inputMask value="#{fornecedorBean.fornecedor.cnpj}"
											id="cnpj" mask="99.999.999/9999-99" required="true"
											requiredMessage="Informe um cnpj válido válido">
										</p:inputMask>
										<span id="erro"> <h:message for="cnpj" /></span>
									</h:panelGroup>

									<h:outputLabel value="E-mail : * " for="email"  style="font-weight:bold" />
									<h:panelGroup>
										<p:inputText id="email" label="e-mail"
											value="#{fornecedorBean.fornecedor.email}" size="30"
											maxLength="50" required="true"
											requiredMessage="Informe um endereço de email válido">
											<f:validateRegex
												pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
										</p:inputText>
										<span id="erro"> <h:message for="email" /></span>
									</h:panelGroup>
									
									
									<h:outputLabel value="Senha: * " for="senha"   style="font-weight:bold" />
							<h:panelGroup>
								<p:password id="senha" label="Senha"
									value="#{fornecedorBean.senha}" size="15" maxlength="25"
									required="#{empty contextoBean.usuarioLogado}"
									redisplay="false" feedback="true"
									requiredMessage="Informe uma senha" weakLabel="Fraca"
									goodLabel="Boa" strongLabel="Forte"
									promptLabel="Por Favor insira uma senha" />
								<span id="erro"> <h:message for="senha" /> </span>
							</h:panelGroup>

							<h:outputLabel value="Confirmar Senha: * " for="confirmarsenha"  style="font-weight:bold" />
							<h:panelGroup>
								<p:password id="confirmarsenha" label="Confirmar Senha"
									value="#{fornecedorBean.confirmaSenha}" size="15" maxlength="20"
									required="#{empty contextoBean.usuarioLogado}"
									redisplay="false" requiredMessage="Confirme senha informada" />
								<span id="erro"> <h:message for="confirmarsenha" /> </span>
							</h:panelGroup>

									<!-- 										<h:outputLabel value="Telefone :" for="telefone" /> -->
									<!-- 										<p:inputMask value="1111111111" mask="(99) 9999-9999" -->
									<!-- 										required="true" -->
									<!-- 										requiredMessage="Informe um número de telefone" /> -->
								</h:panelGrid>

							</div>
						</div>

					</p:fieldset>
				</p:tab>

				<p:tab title="Endereco Fornecedor" closable="false">
					<div id="cadastro">
						<div style="padding-left: 30px; float: left; margin-top: 10px;">


							<h:panelGrid columns="2">
								<h:outputLabel for="cep" value="Cep: *"  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputMask id="cep" value="#{fornecedorBean.endereco.cep}"
										required="true" requiredMessage=" Cep inválido"
										mask="99999-999" size="10" />
									<span id="erro"> <h:message for="cep" /></span>
								</h:panelGroup>

								<h:outputLabel for="logradouro" value="Logradouro : "  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputText id="logradouro" size="30" required="true" requiredMessage=" Logradouro esse campo é obrigatório"
										value="#{fornecedorBean.endereco.logradouro}"
										label="Logradouro" />
									<span id="erro"> <h:message for="logradouro" /></span>
								</h:panelGroup>
								
								<h:outputLabel for="numero" value="Número :"  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputText id="numero" size="10"
										value="#{fornecedorBean.numero}" label="Numero">
									</p:inputText>
									<span id="erro"> <h:message for="numero" />
									</span>
								</h:panelGroup>
								

								<h:outputLabel for="bairro" value="Bairro : "  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputText id="bairro" size="30" required="true" requiredMessage=" Bairro esse campo é obrigatório"
										value="#{fornecedorBean.endereco.bairro}" label="bairro" />
									<span id="erro"> <h:message for="bairro" /></span>
								</h:panelGroup>

								<h:outputLabel for="cidade" value="Cidade : "  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputText id="cidade" size="30" required="true" requiredMessage=" Cidade esse campo é obrigatório"
										value="#{fornecedorBean.endereco.cidade}" label="cidade" />
									<span id="erro"> <h:message for="cidade" /></span>
								</h:panelGroup>

								<h:outputLabel for="uf" value="UF : "  style="font-weight:bold" />
								<h:panelGroup>
									<p:inputText id="uf" size="10" required="true" requiredMessage=" UF esse campo é obrigatório"
										value="#{fornecedorBean.endereco.uf}" label="Uf" />
									<span id="erro"> <h:message for="uf" /></span>
								</h:panelGroup>

								<h:outputLabel for="complemento" value="Complemento : "  style="font-weight:bold" />
								<p:inputText id="complemento" size="20"
									value="#{fornecedorBean.endereco.complemento}"
									label="Complemento" />
							</h:panelGrid>
						</div>
					</div>
				</p:tab>
			</p:accordionPanel>
			<br></br>

			<div style="font-size: 10px; color: red">
				<h:messages />
			</div>

			<h:panelGroup>
				<h:commandButton value="Salvar" action="#{fornecedorBean.salvar}" style="height: 30px"/>
			</h:panelGroup>
		</h:form>

	</ui:define>
</ui:composition>
</html>
